home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / indeo / nwxmas / xd_graph.c < prev    next >
C/C++ Source or Header  |  1993-12-04  |  3KB  |  139 lines

  1.  
  2.  
  3. /*
  4. **    ╔══════════════════════════════════════════════════════════════╗
  5. **    ║                                                              ║
  6. **    ║     Copyright (c) 1993 Digital Video Arts, Ltd.              ║
  7. **    ║                    All Rights Reserved                       ║
  8. **    ║                                                              ║
  9. **    ╚══════════════════════════════════════════════════════════════╝
  10. **
  11. **    Christmas card demo
  12. **
  13. **    file: xd_graph.c - hook after decompression
  14. */
  15. #include <stdio.h>
  16. #include <fcntl.h>
  17. #include "nw.h"
  18. #include "nwerrno.h"
  19. #include "xmasdemo.h"
  20.  
  21. #define LOGODELAY 5*30
  22.  
  23. static long fc = 0L;        // running frame total
  24.  
  25. void AvGraphics(AvS *s, Bitmap *b, Bitmap *b2, long frameno)
  26. {
  27.     Point p1, p2;
  28.     static Rect lr1, lr2;
  29.     static int initialized = 0;
  30.     Rect r1, r2;
  31.     ColorVal c;
  32.     int i;
  33.  
  34.     POINT(p1, 0, 0);
  35.     b->GrPlanes = P_Y;    /* graphics only on Y plane  only*/
  36.     balls->dbm.GrPlanes = P_Y;
  37.     onscreen->dbm.GrPlanes = P_C;
  38.  
  39. //
  40. //    Now, warp each of the three balls
  41. //
  42.  
  43.     for(i=0; i< MAXWARPS; i++) 
  44.         GrCopyMap(&balls->dbm, &warps[i].origin, b, &p1, &map->dbm, 
  45.             &warps[i], 1);
  46. //
  47. //    Now, go through the list of balls and copy the warped image
  48. //    with transparency (blend later..)
  49. //
  50.  
  51.     YVU(c, 0, 0, 0);
  52.  
  53.     for(i=0; i < MAXBALLS; i++) 
  54.         GrCopyTrans(&onscreen->dbm,&Balls[i].p, &balls->dbm,
  55.             &warps[Balls[i].warpno],c);
  56.     RECT(r1, 0, 0, 256, 240);
  57.     RECT(r2, 128+24,18, 128-24,220-38);
  58.     text->dbm.GrPlanes = P_YVU;
  59.     GrScaleFast(&text->dbm, &r2, b, &r1);
  60. //
  61. //    Logo.
  62. //
  63.     CLT(c,0xfe);
  64.     onscreen->dbm.GrPlanes = P_C;
  65.     text->dbm.GrPlanes = P_C;
  66.     if(fc > LOGODELAY && fc < LOGODELAY + 220) {
  67.         POINT(p1, 140,0);
  68.         lr1.origin.x=0; lr1.origin.y = 219 - (fc-LOGODELAY);
  69.         lr1.corner.x = 128; lr1.corner.y = 220-lr1.origin.y;
  70.         GrCopyTrans(&text->dbm,&p1, &text->dbm,&lr1,c);
  71.     }
  72.     if(fc >= LOGODELAY+220) {
  73.         POINT(p1, 140, 0);
  74.         RECT(lr1, 0,0,128,220);
  75.         GrCopyTrans(&text->dbm,&p1, &text->dbm,&lr1,c);
  76.     }
  77.     POINT(p2, 256-64, 240-100);
  78.     onscreen->dbm.GrPlanes = P_YVU;
  79.     GrCopyTrans(&onscreen->dbm,&p2, &text->dbm,&r2,c);
  80.  
  81.     if(!fc++)
  82.         VidShow(onscreen);
  83.         
  84. }
  85.  
  86. #ifdef __NWDLL
  87. #include "nwglobs.hh"
  88. #include "nwwindef.hh"
  89. #endif
  90.  
  91. struct rect21 {
  92.     short argc;
  93.     VAddr    src1;
  94.     int    src1p;
  95.     int    src1bpp;
  96.     VAddr    src2;
  97.     int    src2p;
  98.     int    src2bpp;
  99.     VAddr    dest;
  100.     int    destp;
  101.     int    destbpp;
  102.     int    xsize;
  103.     int    ysize;
  104. };
  105.  
  106. static struct {
  107.     struct rect21 r21;
  108.     int transparency;
  109. } copymap;
  110.  
  111. static McH *vcopymap=0;
  112. Rect21(struct rect21 *, int, Bitmap *, Point *, Bitmap *, Point *, 
  113.     Bitmap *, Rect *);
  114.  
  115. GrCopyMap(Bitmap *destb, Point *destp, Bitmap *src1b, Point *src1p, 
  116.     Bitmap *src2b, Rect *src2r, int trans)
  117. {
  118.     int i, plane;
  119.     
  120.     if(!vcopymap) vcopymap = McFunc("vcopymap");
  121.     if(!vcopymap) return -1;
  122.     if(!destb) return 0;
  123.     
  124.     if((src1b->Type != destb->Type) || 
  125.        (src1b->Type != src2b->Type)) {
  126.         SET_NWERRNO(E_GRINCOMPTYPES);
  127.         return -1;
  128.     }
  129.     
  130.     copymap.r21.argc = sizeof(copymap)/2 - 1;
  131.     copymap.transparency = trans;
  132.     for(i = 0, plane = 1; i< destb->SubPlane; i++, plane <<= 1) {
  133.         if(!Rect21(©map.r21, plane, destb, destp,
  134.                 src1b, src1p, src2b, src2r)) continue;
  135.         McRun(vcopymap, (short *)©map);
  136.     }
  137.     return 1;
  138. }
  139.